import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue'
import legacyPlugin from '@vitejs/plugin-legacy';

export default defineConfig({
    plugins: [
        vue(),
        laravel({
            input: [
                'resources/scss/juheh5.scss',
                'resources/scss/switch_pay/index.scss',
                'resources/scss/switch_pay/info.scss',
                'resources/scss/protocol/index.scss',
                'resources/scss/policy/index.scss',
                'resources/scss/h5sdk/index.scss',
                'resources/scss/h5sdk/pay.scss',
                'resources/scss/h5_toapk/index.scss',
                'resources/js/app.js',
                'resources/js/juheh5.js',
                'resources/js/h5sdk.js',
                'resources/js/repack.js',
                'resources/js/switch_pay.js',
                'resources/js/spin_wheel.js',
                'resources/js/vuecomponents/components.js',
            ],
            refresh: true,
        }),
        legacyPlugin({
            targets: ["chrome < 60", "edge < 15"], // 需要兼容的目标列表，可以设置多个
            additionalLegacyPolyfills: ["regenerator-runtime/runtime"], // 面向IE11时需要此插件
            renderLegacyChunks: true,
        })
    ],
    resolve: {
        // Vue3 默认禁用了运行时编译，因为编译器的体积较大，导致页面加载速度变慢。
        // 如果禁用运行时编译，直接在浏览器上使用 createApp().mount()后，将无法进行挂载，浏览器的dom将为空
        // 如果想要使用基于模板的组件，需要配置构建工具将 vue 模块的别名指向 vue/dist/vue.esm-bundler.js，以启用运行时编译。
        alias: {
            'vue': 'vue/dist/vue.esm-bundler.js'
        }
    }
});
